package com.gszy.auth.mvc;

import java.util.HashMap;
import java.util.Map;

public class BeanFactory {

    private static Map<Class<?>,Object> beans = new HashMap<>();

    public static <T> T getInstance(Class<T> clazz){
        T o = (T) beans.get(clazz);

        if (o == null){
            try {
                o = clazz.newInstance();
            }
            catch (Exception e){
                e.printStackTrace();
            }
        }

        return o;
    }
}
